//
//  GMArtwork.m
//  gentleman
//
//  Created by 范月成 on 2017/12/5.
//  Copyright © 2017年 fancy. All rights reserved.
//

#import "GMArtwork.h"

@implementation GMArtwork

#pragma mark - database

+ (NSString *)dbName {
    return @"GMGentleman_Database";
}
+ (NSString *)tableName {
    return @"GMArtwork_Table";
}
+ (NSString *)primaryKey {
    return @"gid";
}
+ (NSArray *)persistentProperties {
    static NSArray *properties = nil;
    if (!properties) {
        properties = @[
                       @"gid",
                       @"url",
                       @"category",
                       @"filecount",
                       @"posted",
                       @"rating",
                       @"thumb",
                       @"title",
                       @"uploader",
                       @"isDownload",
                       @"isLike",
                       ];
    };
    return properties;
}

- (NSString *)getArtworkLanguage {
    NSString *language = @"";
    NSArray *languageArr = @[
                             @[@"[(\\[]eng(?:lish)?[)\\]]",@"EN"],
                             @[@"[(（\\[]ch(?:inese)?[)）\\]]|[汉漢]化|中[国國][语語]|中文",@"ZH"],
                             @[@"[(\\[]spanish[)\\]]|[(\\[]Español[)\\]]",@"ES"],
                             @[@"[(\\[]korean?[)\\]]",@"KO"],
                             @[@"[(\\[]rus(?:sian)?[)\\]]",@"RU"],
                             @[@"[(\\[]fr(?:ench)?[)\\]]",@"FR"],
                             @[@"[(\\[]portuguese",@"PT"],
                             @[@"[(\\[]thai(?: ภาษาไทย)?[)\\]]|แปลไทย",@"TH"],
                             @[@"[(\\[]german[)\\]]",@"DE"],
                             @[@"[(\\[]italiano?[)\\]]",@"IT"],
                             @[@"[(\\[]vietnamese(?: Tiếng Việt)?[)\\]]",@"VN"],
                             @[@"[(\\[]polish[)\\]]",@"PL"],
                             @[@"[(\\[]hun(?:garian)?[)\\]]",@"HU"],
                             @[@"[(\\[]dutch[)\\]]",@"NL"],
                             ];
    for (NSArray *subArr in languageArr) {
        NSRange range = [self.title rangeOfString:subArr.firstObject options:NSCaseInsensitiveSearch|NSRegularExpressionSearch];
        if (range.location != NSNotFound) {
            language = subArr[1];
            break;
        }
    }
    return language;
}

@end
